//
// Created by liushuai on 2020/6/6.
//
#include "multiply.h"
string multiply(string s1,string s2){
    vector<char> residual = vector<char>(s1.length()+s2.length(),'0');
    string result = "";
    int len_s1 = s1.length();
    int len_s2 = s2.length();
    for(int index_s1 = len_s1-1;index_s1>=0;index_s1--){
        for(int index_s2=len_s2-1;index_s2>=0;index_s2--){
            int value = (s1[index_s1]-'0')*(s2[index_s2]-'0')+residual[index_s1+index_s2+1];
            residual[index_s1+index_s2+1] = value%10+'0';
            residual[index_s1+index_s2] = value/10+residual[index_s1+index_s2];
        }
    }
    return result;
}

